home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
CheckedHelpEditor.cpp
< prev
next >
Wrap
Text File
|
1997-08-10
|
6KB
|
243 lines
/*
* File: CheckedHelpEditor.cpp
* Summary: A view that knows how to edit a control's checked help message.
* Written by: Jesse Jones
*
* Copyright ゥ 1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <2> 4/06/97 JDJ Updated for new style TSubPaneIterator.
* <1> 2/05/97 JDJ Created
*/
#include "CheckedHelpEditor.h"
#include <ZRadioButton.h>
#include <ZStaticText.h>
#include <ZStringUtils.h>
#include <ZTextBox.h>
// ===================================================================================
// class CEditCheckedHelpCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CEditCheckedHelpCommand::~CEditCheckedHelpCommand
//
//---------------------------------------------------------------
CEditCheckedHelpCommand::~CEditCheckedHelpCommand()
{
}
//---------------------------------------------------------------
//
// CEditCheckedHelpCommand::CEditCheckedHelpCommand
//
//---------------------------------------------------------------
CEditCheckedHelpCommand::CEditCheckedHelpCommand(TControl* pane, const SControlInfo& oldInfo, const SControlInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
{
}
//---------------------------------------------------------------
//
// CEditCheckedHelpCommand::UpdatePane
//
//---------------------------------------------------------------
void CEditCheckedHelpCommand::UpdatePane(const SControlInfo& info)
{
mPane->SetCheckedHelpMessage(info.checkedMesg);
}
#pragma mark -
// ===================================================================================
// CCheckedHelpEditor
// ===================================================================================
static TReanimatorRegister<CCheckedHelpEditor> sCheckedHelpEditorRegistrar;
//---------------------------------------------------------------
//
// CCheckedHelpEditor::~CCheckedHelpEditor
//
//---------------------------------------------------------------
CCheckedHelpEditor::~CCheckedHelpEditor()
{
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::CCheckedHelpEditor
//
//---------------------------------------------------------------
CCheckedHelpEditor::CCheckedHelpEditor(TView* superView) : Inherited(superView)
{
mType = '????';
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CCheckedHelpEditor::Create(MReanimatable* parent)
{
return new CCheckedHelpEditor(dynamic_cast<TView*>(parent));
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::OnReanimated
//
//---------------------------------------------------------------
void CCheckedHelpEditor::OnReanimated()
{
Inherited::OnReanimated();
TSubPaneIterator iter = this->begin();
while (iter != this->end()) {
TPane* pane = *iter;
++iter;
if (TRadioButton* button = dynamic_cast<TRadioButton*>(pane))
button->AddListener(this);
}
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::OnBroadcast
//
//---------------------------------------------------------------
void CCheckedHelpEditor::OnBroadcast(const SControlMessage& mesg)
{
if (mesg.value == 1) {
mType = StrToID(mesg.message);
this->TogglePanes();
}
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::TogglePanes
//
//---------------------------------------------------------------
void CCheckedHelpEditor::TogglePanes()
{
TStaticText* caption = dynamic_cast<TStaticText*>(this->FindSubPane("ID Caption"));
if (mType == 'STRL') {
caption->Hide();
this->FindSubPane("String Literal")->Show();
this->FindSubPane("Rsrc ID")->Hide();
} else {
caption->SetText("Rsrc ID:");
this->FindSubPane("String Literal")->Hide();
this->FindSubPane("Rsrc ID")->Show();
}
if (mType == 'STR#') {
this->FindSubPane("Index Caption")->Show();
this->FindSubPane("STR# Index")->Show();
} else {
this->FindSubPane("Index Caption")->Hide();
this->FindSubPane("STR# Index")->Hide();
}
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::GetEditorInfo
//
//---------------------------------------------------------------
SControlInfo CCheckedHelpEditor::GetEditorInfo() const
{
SControlInfo info;
TTextBox* id = dynamic_cast<TTextBox*>(this->FindSubPane("Rsrc ID"));
switch (mType) {
case 'STR ':
case 'TEXT':
case 'PICT':
info.checkedMesg = THelpMessage(mType, id->GetValue());
break;
case 'STR#':
TTextBox* index = dynamic_cast<TTextBox*>(this->FindSubPane("STR# Index"));
info.checkedMesg = THelpMessage(mType, id->GetValue(), index->GetValue());
break;
case 'STRL':
TTextBox* str = dynamic_cast<TTextBox*>(this->FindSubPane("String Literal"));
info.checkedMesg = THelpMessage(str->GetText());
break;
default:
DEBUGSTR("CCheckedHelpEditor::GetHelpMesg had a bogus type.");
}
return info;
}
//---------------------------------------------------------------
//
// CCheckedHelpEditor::SetEditorInfo
//
//---------------------------------------------------------------
void CCheckedHelpEditor::SetEditorInfo(const SControlInfo& info)
{
mType = info.checkedMesg.GetType();
TTextBox* id = dynamic_cast<TTextBox*>(this->FindSubPane("Rsrc ID"));
switch (mType) {
case 'STR ':
case 'TEXT':
case 'PICT':
id->SetValue(info.checkedMesg.GetID());
break;
case 'STR#':
TTextBox* index = dynamic_cast<TTextBox*>(this->FindSubPane("STR# Index"));
id->SetValue(info.checkedMesg.GetID());
index->SetValue(info.checkedMesg.GetIndex());
break;
case 'STRL':
TTextBox* str = dynamic_cast<TTextBox*>(this->FindSubPane("String Literal"));
str->SetText(info.checkedMesg.GetStringLiteral());
break;
default:
DEBUGSTR("CCheckedHelpEditor::SetHelpMesg had a bogus type.");
}
TRadioButton* button = dynamic_cast<TRadioButton*>(this->FindSubPane(IDToStr(mType)));
if (button != nil)
button->SetValue(1);
this->TogglePanes();
}